﻿using System;
using System.Collections.Generic;
using System.Text;
using SwinGame;

namespace Survivor.src
{
    class Camera
    {
        Point2D _maxRange;
        Point2D _position;
        TerrainManager _terrainManager;

        internal TerrainManager TerrainManager
        {
            get { return _terrainManager; }
            set { _terrainManager = value; }
        }
        public Point2D Position
        {
            get { return _position; }
            set { _position = value; }
        }
        public Point2D MaxRange
        {
            get { return _maxRange; }
            set { _maxRange = value; }
        }
        List<List<bool> > _visibleTiles; //What format?? how does it refer to tiles?//

        public bool isPointInView(int x, int y)
        {
            float min_x = Position.X - MaxRange.X;
            float max_x = Position.X + MaxRange.X;
            float min_y = Position.Y - MaxRange.Y;
            float max_y = Position.Y + MaxRange.Y;
            if (x >= min_x && x < max_x)
            {
                if (y > min_y && y <= max_y)
                {
                    return true;
                }
            }
            return false;
        }

        public bool isPointInView(Point2D p)
        {
            float min_x = Position.X - MaxRange.X;
            float max_x = Position.X + MaxRange.X;
            float min_y = Position.Y - MaxRange.Y;
            float max_y = Position.Y + MaxRange.Y;
            if (p.X >= min_x && p.X < max_x)
            {
                if (p.Y > min_y && p.Y <= max_y)
                {
                    return true;
                }
            }
            return false;
        }
        public bool isRangeInView(bool isHorizontal, int val, int range)
        {
            float min = 0, max = 0;
            if (isHorizontal)
            {
                min = Position.X - MaxRange.X;
                max = Position.X + MaxRange.X;
            }
            else
            {
                min = Position.Y - MaxRange.Y;
                max = Position.Y + MaxRange.Y;
            }
            bool in_x = (val >= min - range && val < max);
            bool in_y = (val > min && val < max + range);

            if (isHorizontal) { return in_x; } else { return in_y; }
        }
    }
}
